﻿using JobBack.Models;
using QG.JobBack.BLL.IService;
using QG.JobBack.DAL;
using QH.JobBack.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace JobBack.Controllers
{
    public class FeedBackController : Controller
    {
        private IFeedBackService ifeedBackService;
        private Opretation opretation=new Opretation();
        public FeedBackController(IFeedBackService ifeedBackService)
        {
            this.ifeedBackService = ifeedBackService;
        }
        /// <summary>
        /// 留言反馈页面
        /// </summary>
        /// <returns></returns>
        public ActionResult Feedback()
        {
            return View();
        }
        //查询所有反馈信息
        public JsonResult QueryFeedBackAll(int page, int limit, string UserName,Nullable<DateTime> FeedTime, Nullable<bool> IsLook)
        {
            List<FeedbackBase> feedBackBases  = ifeedBackService.QueryFeedBackAll(UserName, FeedTime, IsLook);

            ResponseResult<FeedbackBase> getJson = new ResponseResult<FeedbackBase>()
            {
                msg = "",
                code = 0,
                count = feedBackBases.Count,
                data = feedBackBases.Skip((page - 1) * limit).Take(limit).ToList()
            };
            return Json(getJson, JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 删除一条反馈信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public JsonResult DeleteFeedBackInfo(int id)
        {

            opretation.Success = ifeedBackService.Delete(id);
            return Json(opretation);
        }
        /// <summary>
        /// 回复一条反馈信息
        /// </summary>
        /// <param name="AdminId"></param>
        /// <param name="FId"></param>
        /// <param name="Context"></param>
        /// <returns></returns>
        public JsonResult ReplyFeedBackInfo(int FId,string Context)
        {
            Reply reply = new Reply();
            reply.FId = FId;
            reply.Context = Context;
            reply.AdminId = 1;
            Opretation opretation = new Opretation();
            opretation.Success = ifeedBackService.ReplyFeedBackInfo(reply, FId);
            return Json(opretation);
        }
        /// <summary>

    }
}